1. Introduction to LaTeX
Using is practically inevitable for anyone who wishes to graduate with a mathematics degree from ETH, and we recommend getting familiar with the syntax as soon as possible.

Therefore every lecture will be accompanied by a brief post dedicated to learning how to use . Together these posts will constitute a somewhat opinionated and whimsical introduction to typesetting professional mathematics. No prior knowledge of the subject is assumed.
Installing LaTeX
Before you can begin playing with , you need access to a distribution. There are essentially two ways to do this:
- Install a distribution on your computer.
- Use a browser-based solution.
There are advantages and disadvantages to both methods. You will probably eventually want a distribution installed on your computer, since even if you primarily work in your browser, it is useful to be able to open .tex
files locally. To obtain a distribution, go here and follow the installation instructions for your operating system of choice.
is free software. However there also exist commercial editors. Of these I like Texpad (which is Mac/iOS only), although I do most of my work using the free LaTeXTools plugin for Sublime Text.
In the short term, however, it is easier to use a browser-based solution, since this doesn't require installing any special software. There are several competing products:
- Overleaf,
- LaTeX Base,
- CoCalc,
- and many more...
All of these are free for basic use, but allow you to subscribe to a paid plan for more features. My personal favourite is Overleaf. Moreover ETH has purchased an institutional license for Overleaf, which means if you sign up using your ETH email address then you get the paid features for free.
For this reason, the rest of these tutorial lectures will assume that you are using Overleaf.
Aside: Overleaf also has a excellent online knowledge base for learning . It is far more comprehensive than my notes will ever be!
The Absolute Basics
Consider the following very short file:
To turn these four lines into a file, simply save them to your computer with a .tex
extension. If we feed this file to a compiler, it will produce for us a PDF. It looks like this:

Note that only one of the four lines actually got printed. Let us explain why. Every document consists of two parts:
- The preamble.
- The content.
The content of the document is everything between the \begin{document}
and \end{document}
. This is what gets typeset (= printed).
The preamble is everything that comes before the \begin{document}
line. This is where we tell what type of document we'd like to create. In our simple example the preamble consisted of the single line \documentclass{article}
. This line is not optional: will throw an error if we omit it. We chose the class article
, which is the default option and will suffice for everything we do today.
Here is another thrilling file:
This produces:

This
time the preamble had three extra lines. We specified the title, the
author, and the date. Then we added an extra line to the document
itself: \maketitle
. This tells to typeset the information we gave it.
Pro Tip: If you want to just use today's date, you can write \date{\today}
.
So how do I type maths?
Inserting maths is easy. We simply invoke math mode. There are two types of math mode, depending whether we want the maths to appear on the same line as the surrounding text, or whether we want it to appear on its own line. The former is called inline math mode, whereas the latter is called displayed math mode.
Inline math mode is entered via the \begin{math}
command and exited via the \end{math}
command. Meanwhile displayed math mode is entered via the \begin{displaymath}
command and exited by the \end{displaymath}
command.
Here is a more complicated document that illustrates this.
This gives us:

Let us go through the various math elements we introduced step-by-step.
- Greek letters: To write a Greek letter, we type a backslash, followed by the name of the letter. Thus
\alpha
produces . - To write an exponent, use a caret ^. Thus
n^2
gives us . If the exponent has more than one character, it needs to be wrapped in curly brackets. Thusn^{34}
gives . - The summation symbol: We wrote
\sum
to produce the summation symbol . Moreover we use an underscore with curly brackets_{...}
to specify the lower range of the summation and a caret with curly brackets^{...}
to specify the upper range of the summation. - Fractions: To create a fraction we write
\frac{a}{b}
. Note that both the summation symbol and the fraction have a slightly different appearance depending as to whether we are in inline mode or displayed mode. - The number infinity: The command for infinity is
\infty
.
As you can see, some commands are easier to guess than others. They will all eventually become second nature. You can find a comprehensive reference list here, although my advice is just to pick things up as you go along.
Typing out \begin{math} ... \end{math}
and \begin{displaymath} ... \end{displaymath}
every time we want to enter or exit math mode rapidly becomes tedious. So you will pleased to know there are shorter versions:
Short version | Really short version | |
---|---|---|
Inline | \( ... \) |
$ ... $ |
Displayed | \[ ... \] |
$$ ... $$ |
Warning: experts will tell you not to use the “really short version” $$ ... $$
for displayed math. This is because it is a deprecated command from the original plain syntax. As a result, using $$ ... $$
can cause errors in some weird edge cases (for instance, when used in tandem with \fleqn
). For more information about this see here. Throughout the rest of these notes, we will use $ ...$
for inline maths, and \[ ... \]
for displayed maths.
Packages
can be extended by enabling additional packages. This is done via the \usepackage
command in the preamble. There are hundreds and hundreds of packages to choose from, but in practice you won't need that many.
There are however three key packages that you will probably end up using in every single document you write. They are designed to enable advanced mathematical typesetting, and were all developed by the American Mathematical Society. They are:
amsmath
amssymb
amsthm
The simplest to understand of these is the middle one, amssymb
. This package gives access to certain common mathematical fonts and symbols.
For example, amssymb
unlocks the “blackboard font” that is typically used to denote fields (eg. the real numbers , the rational numbers , and the complex numbers ). Let us see this in action:
This gives us:

To get the special font we wrote \mathbb{C}
(inside math mode). The “bb” stands for “blackboard”. This only works because we invoked the amssymb
package in the preamble. Other amssymb
fonts can be accessed similarly:
Command | Alphabet | Appearance |
---|---|---|
\mathbb |
Blackboard | |
\mathcal |
Calligraphic | |
\mathfrak |
Fraktur |
Note also that the symbol is given by the command \in
.
Moreover this time the title contained several letters with diacritics. Diacritics in are mostly easy to guess:
- An umlaut is given by
\"
. Thus Ü is\"U
and ö is\"o
. - An accent is given by
\'
. Thus é is\'e
. - To get ß, one types
\ss
.
Finally, observe that in “Größe” we wrote Gr\"o\ss e
, deliberately leaving a space after the \ss
. If we omitted this space, would try and parse \sse
as a command and throw an error. Nevertheless, does not print this extra space. We will discuss spacing more in the next tutorial.
Warning: If you are using an old (pre-2018) version of , you will sometimes need to add the line \usepackage[utf8]{inputenc}
to your preamble to handle certain accents correctly. This loads the package inputenc
(which is short for “Input Encoding”) with the utf8
option. However in new versions of this is loaded automatically, so you don't need to bother.
That's it for today. In the next installment we'll discuss formatting and styling text, and the package amsmath
. In the third installment we'll discuss the final key package amsthm
, which allows us to add Theorems and Proofs and whatnot to our documents.
By Christmas you will all be typesetting gurus, ready to pour scorn upon your Microsoft Word-using friends.
Comments and questions?